package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F60.3.8：账户结算类型
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F60_3_8_AcctSettleTypeEnum {
    _00("00", "未知,按借记卡定价"),
    _01("01", "借记账户,按借记卡定价"),
    _02("02", "贷记账户,按贷记卡定价"),
    _03("03", "准贷记账户,按贷记卡定价"),
    _04("04", "借贷合一账户,按卡bin归属定价"),
    _05("05", "预付费账户,按借记卡定价或按协议定价"),
    _06("06", "半开放预付费账户,按借记卡定价或按协议定价"),
    ;

    private String code;
    private String desc;

    F60_3_8_AcctSettleTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F60_3_8_AcctSettleTypeEnum find(String code) {
        F60_3_8_AcctSettleTypeEnum result = Arrays.stream(F60_3_8_AcctSettleTypeEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
